import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;


public class Parser {
	public Parser (){}

	public Parser (String folder, String key){
		File dir = new File(folder);
		if(dir.isDirectory()){
			String s[] = dir.list();
			for(int i=0; i<s.length; i++){
				File f=new File(folder + "\\" + s[i]);

				/*	try{
					RandomAccessFile raf = new RandomAccessFile(f, "r");
					raf.seek(0);
					for (int j=1;j<raf.length();j++){
						if ()
						{
							String line = raf.readLine();
							System.out.println(line);
						}
					}

				}catch (FileNotFoundException ex){
					System.out.println("File not found");
				} catch (IOException ex){
					System.out.println("IO Exception");
				}*/




				try {
					FileInputStream fis = new FileInputStream(f.getPath());
					InputStreamReader isr = new InputStreamReader(fis);
					BufferedReader inStream = new  BufferedReader(isr);

					while(inStream.ready()){
						String str=inStream.readLine();
						if (str.contains(key))
							System.out.println(inStream.readLine());
						break;

					}
					fis.close();
					isr.close();
					inStream.close();
				} catch (FileNotFoundException ex){
					System.out.println("File not found");
				} catch (IOException ex){
					System.out.println("IO Exception");
				} 
			}
		}
	}

	/*	public byte [] getBlock(String key){
			return 0;
		}*/

	public static void main (String [] args){
		Parser p = new Parser("fold", "===ggg===");
	}
}
